﻿@model AuthorizationCode
@{
    ViewData["Title"] = Model.tenantName;
    var code = Context.Request.Query["code"];
    var state = Context.Request.Query["state"];
    var client = ViewBag.client as OAuthApp.Data.App;
    var redirect_uri = new Uri(Model.redirect_uri);
    var cancelUri = redirect_uri.Scheme + "://" + redirect_uri.Authority + redirect_uri.AbsolutePath;
}
@if (Model != null)
{
<div class="container-fluid">
    <div class="row">
        <div class="col-sm-12 col-md-6 offset-md-3 d-flex align-items-start justify-content-center"
             style="height: 100vh;">
            <div style="width:80%" class="mt-5">
                <div class="card">
                    <div class="card-body">
                        <div class="d-flex text-center">
                            <div class="w-50">
                                <label class="form-label">当前账户：<b>@Model.userName</b></label>
                                    <form asp-action="SignOut" asp-controller="OAuth">
                                        <input type="hidden" name="code" value="@code" />
                                        <button class="btn btn-link">切换账号</button>
                                    </form>
                            </div>
                            <div class="align-items-center align-content-center">
                                <span> ✔ </span>
                            </div>
                            <div>
                                <div>
                                    <img src="@client.Logo" width="48px" />
                                </div>
                                <div class="mx-2">
                                    <h4 class="m-0">@client.Name</h4>
                                    <p class="mt-1">@client.Website</p>
                                </div>
                            </div>
                        </div>

                        <hr />

                        <div class="mb-3">
                            <label class="form-label">申请以下权限</label>
                            <div><code>@Model.scope</code></div>
                        </div>
                        <form action="/OAuth/ConsentPost" method="post">
                            <input type="hidden" name="code" value="@code" />
                            <input type="hidden" name="state" value="@state" />
                            <button type="submit" class="btn btn-success">确认授权</button>
                            <a href="@cancelUri" class="btn btn-light">撤销</a>
                        </form>

                    </div>

                </div>
            </div>
        </div>
    </div>
</div>
        }
